package com.fix.day1;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestBean {
	
	String name; 
	UserDao dao;
	List list;    //没有new
	
	public TestBean(String name,UserDao dao) {
		this.name = name;
		this.dao = dao;
	}

	public void setList(List list) {
		this.list = list;
	}

	public void hello() {
		System.out.println(name+" bean ="+ this.hashCode());
		dao.login("", "");
		System.out.println("好朋友集合"+list);
	}
	
	public static void main(String[] args) {
		// 启动Spring 容器
		ApplicationContext context1 = new ClassPathXmlApplicationContext("classpath:spring.xml");
		TestBean obj1 = (TestBean)context1.getBean("temo");
		
		ApplicationContext context2 = new ClassPathXmlApplicationContext("classpath:spring.xml");
		TestBean obj2 = (TestBean)context2.getBean("temo");
		System.out.println( obj1 == obj2 );
		obj1.hello();
		obj2.hello();
		
//		obj.hello();
	}

}
